package cn.fl.system.transform;

import java.util.ArrayList;
import java.util.List;

import cn.cmm.base.framework.utils.CollectionUtils;
import cn.fl.system.vo.SysFlowTaskHVO;
import fl.flow.facade.flow.dto.SysFlowTaskHDTO;

 /**
 * @Description: 流程任务节点操作历史 转换器
 * VO是客户端传递数据到服务端进行转换的数据 
 * VO转换数据变成DTO传递到服务端 
 * VO不能在服务端出现
 */
public class SysFlowTaskHVOTransform {


	/**
	 * DTO 转  VO
	 * @param po SysFlowTaskHDTO
	 * @return SysFlowTaskHVO
	 */
	public static SysFlowTaskHVO toVO(SysFlowTaskHDTO dto) {
		SysFlowTaskHVO  vo = null;
		if (dto != null) { 
			vo = new SysFlowTaskHVO();
			vo.setId(dto.getId());
			vo.setProcDefKey(dto.getProcDefKey());//流程定义标识
			vo.setProcDefId(dto.getProcDefId());//流程定义ID
			vo.setProcInstId(dto.getProcInstId());//流程实例ID
			vo.setTaskId(dto.getTaskId());//任务ID
			vo.setTaskDefKey(dto.getTaskDefKey());//任务定义Key
			vo.setBusinessKey(dto.getBusinessKey());//业务数据主键
			vo.setTaskOpinion(dto.getTaskOpinion());//审批意见
			vo.setSysCd(dto.getSysCd());//系统代码
			vo.setIsDel(dto.getIsDel());//是否删除
			vo.setAttchmntList(dto.getAttchmntList());
			vo.setBusinessType(dto.getBusinessType());
			vo.setToUsrIdList(dto.getToUsrIdList());
			vo.setBusinessBean(dto.getBusinessBean());

			vo.setCrtTm(dto.getCrtTm());//创建时间
			vo.setCrtUsrId(dto.getCrtUsrId());//创建人
			vo.setMdfTm(dto.getMdfTm());//修改时间
			vo.setMdfUsrId(dto.getMdfUsrId());//修改人
		}
		return vo;
	}

	/**
	 * VO 转 DTO
	 * @param dto SysFlowTaskHVO
	 * @return SysFlowTaskHDTO
	 */
	public static SysFlowTaskHDTO toDTO(SysFlowTaskHVO vo) {
		SysFlowTaskHDTO dto = null;
		if (vo != null) {
			dto = new SysFlowTaskHDTO();
			dto.setId(vo.getId());
			dto.setProcDefKey(vo.getProcDefKey());//流程定义标识
			dto.setProcDefId(vo.getProcDefId());//流程定义ID
			dto.setProcInstId(vo.getProcInstId());//流程实例ID
			dto.setTaskId(vo.getTaskId());//任务ID
			dto.setTaskDefKey(vo.getTaskDefKey());//任务定义Key
			dto.setBusinessKey(vo.getBusinessKey());//业务数据主键
			dto.setTaskOpinion(vo.getTaskOpinion());//审批意见
			dto.setSysCd(vo.getSysCd());//系统代码
			dto.setIsDel(vo.getIsDel());//是否删除
			dto.setAttchmntList(vo.getAttchmntList());
			dto.setBusinessType(vo.getBusinessType());
			dto.setToUsrIdList(vo.getToUsrIdList());
			dto.setBusinessBean(vo.getBusinessBean());

			dto.setCrtTm(vo.getCrtTm());//创建时间
			dto.setCrtUsrId(vo.getCrtUsrId());//创建人
			dto.setMdfTm(vo.getMdfTm());//修改时间
			dto.setMdfUsrId(vo.getMdfUsrId());//修改人
		}
		return dto;
	}
	
	/**
	 * DTO集合 转 VO集合
	 * @param list List<SysFlowTaskH>
	 * @return List<SysFlowTaskHDTO>
	 */
	public static List<SysFlowTaskHVO> toVOList(List<SysFlowTaskHDTO> list) {
		List<SysFlowTaskHVO>  voList = new ArrayList<SysFlowTaskHVO>();
		if(CollectionUtils.isNotEmpty(list)){
			for (SysFlowTaskHDTO dto : list) {
				voList.add(toVO(dto));
			}
		}
		return voList;
	}
}
